﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Farm;
using iControl;

namespace F5LoadBalancer {
    [WebFarmOperationProvider]
    public class F5DisableLoadBalancingOperationProvider : WebFarmOperationProvider {
        public override string Name {
            get {
                return ProviderName;
            }
        }

        public override IEnumerable<OperationParameter> Parameters {
            get {
                yield return new OperationParameter(
                    AddServerOperationProvider.ServerParameterName,
                    Resources.ServerParameterDescription,
                    typeof(ServerContext));
            }
        }

        public override object RunOperation(WebFarmOperationContext operationContext) {
            ServerContext serverContext = (ServerContext)operationContext.Options.Parameters[0].Value;
            Utility.SetPoolMemberState(serverContext.WebFarm.Name, serverContext.Address, CommonEnabledState.STATE_DISABLED);
            return null;
        }

        public override ProviderDisposition Disposition {
            get {
                return ProviderDisposition.Hidden;
            }
        }

        public const string ProviderName = F5Constants.F5LoadBalancerName + DisableLoadBalancingOperationProvider.ProviderName;
    }
}
